/**
 * Multiline text area control.
 *
 * @author Andrey Anisimov <hercules@inbox.ru>
 */

import core.ui.FocusWindow;

class TextArea extends FocusWindow {

	/**
	 * Creates new text area.
	 * 
	 * @param parent (Window) [optional] parent window
	 * @param x, y (int) [optional] coordinates
	 * @param width, height (int) [optional] text area size.
	 */
	this.TextArea = function(parent, x, y, width, height) {
		super(parent, x, y, width, height);
		// FIX: Provide text selection for IE4+
		if (this.getElement().onselectstart)
			this.getElement().onselectstart = new Function('window.event.cancelBubble = true');
	}
	
	this.setName = function(name) {
		this.getElement().name = name;
	}
	
	this.getName = function() {
		return this.getElement().name;
	}
	
	this.setValue = function(value) {
		this.getElement().value = value;
	}
	
	this.getValue = function() {
		return this.getElement().value;
	}
	
	this.setText = function(text) {
		this.setValue(text);
	}
	
	this.getText = function() {
		return this.getValue();
	}
	
	/**
	 * @protected
	 * Creates and returns root element for textarea control.
	 * 
	 * @return HTMLElement
	 */
	this.createElement = function() {
		return document.createElement('textarea');
	}
}